import { _decorator, Component, Node } from 'cc';
import { Const } from './Const';
const { ccclass, property } = _decorator;

@ccclass('SurroundSword')
export class SurroundSword extends Component {

    private angleSpeed: number = 4;
    public isMoving: boolean = true;

    protected onEnable(): void {
        for (let i = 0; i < this.node.children.length; i++) {
            this.node.children[i].angle = i * 120;

        }

    }

    protected onDisable(): void {

    }
    start() {

    }

    update(deltaTime: number) {
        if (!this.isMoving) return;

        if (Const.ndPlayer) {
            this.node.setWorldPosition(Const.ndPlayer.worldPosition.x, Const.ndPlayer.worldPosition.y, 0);
        }

        for (let i = 0; i < this.node.children.length; i++) {
            this.node.children[i].angle += this.angleSpeed;
        }

    }
}


